// Grammar.h: interface for the Grammar class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GRAMMAR_H__D7C204A9_F6C5_4DE0_A21B_41517D6691A0__INCLUDED_)
#define AFX_GRAMMAR_H__D7C204A9_F6C5_4DE0_A21B_41517D6691A0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <string>
#include <list>
#include "Production.h"
#include "Lexical.h"

using namespace std;

typedef struct{
	string code;
}att_X;

typedef struct{
	string code;
	int begin,next;
	bool isLoop;
}att_S;

typedef struct{
	string code;
	int begin,next;
	bool isElse;
}att_S1;

typedef struct{
	string code;
	int isTrue,isFalse;
}att_C;

typedef struct{
	string code;
	string place;
}att_C1;

typedef struct{
	string code;
	string place;
}att_E;

typedef struct{
	string code;
	string place;
}att_E1;

typedef struct{
	string code;
	string place;
}att_T;

typedef struct{
	string code;
	string place;
}att_T1;

typedef struct{
	string code;
	string place;
}att_F;

class Grammar  
{
public:
	char* F(char* ch);
	char* T1(char* ch);
	char* T(char* ch);
	char* E1(char* ch);
	char* E(char* ch);
	char* C1(char* ch);
	char* C(char* ch);
	char* S1(char* ch);
	char* S(char* ch);
	char* X(char* ch);
	void addProduction(string var,string f);
	Grammar();
	virtual ~Grammar();
	list<string> VariableList;

private:
	int ifEisFirst;
	int ifTisFirst;
	att_X tempX;
	att_S tempS;
	att_S1 tempS1;
	att_C tempC;
	att_C1 tempC1;
	att_E tempE;
	att_E1 tempE1;
	att_T tempT;
	att_T1 tempT1;
	att_F tempF;
	int ifJump;

public:
	void clear();
	string newtemp();
	int tempNum;
	int newlabel();
	list<Production> GrammarList;
	//Lexical lex;

};

#endif // !defined(AFX_GRAMMAR_H__D7C204A9_F6C5_4DE0_A21B_41517D6691A0__INCLUDED_)
